{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#初次运行请先clone\n",
    "!git clone https://gitee.com/extrame/ai-theme-maker.git\n",
    "!cp -r ai-theme-maker/* ./"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#非首次运行可以直接git pull\n",
    "!cd ai-theme-maker && git pull\n",
    "!cp -r ai-theme-maker/* ./"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#安装，配置，运行\n",
    "!yarn\n",
    "!yarn build"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#查找dist/assets下面的文件名称，然后将其复制到下面的变量中\n",
    "import os\n",
    "files = os.listdir('dist/assets')\n",
    "file_path = 'dist/assets/' + files[0]\n",
    "\n",
    "content = f\"\"\"\n",
    "import streamlit as st\n",
    "import streamlit.components.v1 as components\n",
    "\n",
    "def picker_component():\n",
    "    # 读取 JavaScript 文件\n",
    "    with open('{file_path}', 'r') as f:\n",
    "        js_code = f.read()\n",
    "    components.html(f'''\n",
    "    <script>\n",
    "{{js_code}}\n",
    "</script>\n",
    "        <ai-colorpicker></ai-colorpicker>\n",
    "    ''',scrolling=True, height=800)\n",
    "\n",
    "picker_component()\n",
    "\"\"\"\n",
    "#write to app.streamlit.py\n",
    "with open('app.streamlit.py', 'w') as f:\n",
    "    f.write(content)\n"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
